package cn.itsource.pethome.order.controller;

import cn.itsource.pethome.order.service.IOrderAddressService;
import cn.itsource.pethome.order.service.IOrderProductService;
import cn.itsource.pethome.user.domain.User;
import cn.itsource.pethome.utils.AjaxResult;
import cn.itsource.pethome.utils.UserContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/order")
public class OrderProductController {

    @Autowired
    private IOrderProductService orderProductService;

    @PostMapping("/createOrder")
    public AjaxResult createOrder(@RequestBody Map<String,String> map, HttpServletRequest request){
        User user = UserContext.getUser(request);
        return orderProductService.createOrder(map,user);
    }
}
